import requests
import time

# python标准，函数之间空两行
def add_user_data():
    url = 'http://127.0.0.1:8081/user/addOne'
    for i in range(100):
        param = dict()
        param['userId'] = '027' + str(i)
        param['pwd'] = 'ddd'
        param['name'] = 'I am  roader' + str(i)
        param['role'] = 'customer'
        param['age'] = 12 + i
        param['gender'] = 0
        param['phoneNumber'] = '121322' + str(i)

        # 一般都是创建一个新的线程，该线程挂了，不影响其他线程。
        ret = requests.post(url, param)
        print(ret)


def query_user():
    url ='http://localhost:8089/iam/user/username/'
    for i in range (1000):
        url2 = url+ "name14000"+ str(i)
        ret  = requests.get(url2)
        print(ret.text)
        print(ret)

def query_fault_wr():
    url ="http://sany-heavy-energy-as.bdn-saas-iot-qa.rootcloudapp.com/api/maintenance/fault/load"
    param = dict()
    param["sheId"]='5c1db86dfe059ac35821def9c9847a77'
    start = time.time()
    ret = requests.post(url,param)
    duration = time.time() - start;
    print(str(duration)+"ms")
    print(ret.text)

query_user()